import { setRoutes } from './main'
import { useSetting } from './settings'
// 自定义组件
import IconfontSelect from './components/IconfontSelect'
import CrudCodemirrorInput from './components/codeMirror'
import SvgIcon from './components/svg-icon'
import AsideContainer from './components/layout/container/aside-container'
import GroupTable from './components/display/group-table'
import PageTable from './components/display/page-table'
import EmptyImg from './components/display/empty'
import NoData from './components/display/empty/no-data'

const components = [
  IconfontSelect,
  CrudCodemirrorInput,
  SvgIcon,
  AsideContainer,
  PageTable,
  GroupTable,
  EmptyImg,
  NoData
]
const install = function (Vue, opts = {}) {
  components.forEach(component => {
    Vue.component(component.name, component)
  })
  useSetting(opts.setting)
  setRoutes(opts.appRoutes, opts.fetchApp)
}

if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue)
}

export default {
  install,
  ...components
}

export { default as store } from './store'
export { default as commonRoute } from './router/commonRoute'
export { default as ajax } from './utils/request'
export { default as mixins } from './mixins'
export { default as setting } from './settings'
